<template>
  <div>
    <!-- 全局的三级菜单 -->
    <TypeNav />
    <!-- 轮播图和欢乐购快报组件 -->
    <ListContainer />
    <!-- 今日推荐 -->
    <Recommend />
    <!-- 热卖排行 -->
    <Rank />
    <!-- 猜你喜欢 -->
    <Like />
    <!-- Floor组件的数据是父组件传递过去的 -->
    <Floor v-for="(floor, index) in floorList" :key="floor.id" :list="floor" />
    <!-- 各大品牌组件 -->
    <Brand />
  </div>
</template>

<script>
import Brand from "@/pages/home/brand/Brand";
import Floor from "@/pages/home/floor/Floor";
import Like from "@/pages/home/like/Like";
import ListContainer from "@/pages/home/listContainer/ListContainer";
import Rank from "@/pages/home/rank/Rank";
import Recommend from "@/pages/home/recommend/Recommend";
import { mapState } from "vuex";
export default {
  name: "Home",
  components: {
    Brand,
    Floor,
    Like,
    ListContainer,
    Rank,
    Recommend,
  },
  //组件挂载完成后执行
  mounted() {
    //派发 action，获取 Floor 楼层数据
    this.$store.dispatch("getFloorList");
  },

  //通过 计算属性+mapState 获取仓库数据
  computed: {
    ...mapState({
      floorList: (state) => state.home.floorList,
    }),
  },
};
</script>

<style>
</style>